package com.ruoyi.smartcity.huanjing.controller;

import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.smartcity.huanjing.domain.HuanjingKongqizhiliang;
import com.ruoyi.smartcity.huanjing.service.IHuanjingKongqizhiliangService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 空气质量Controller
 * 
 * @author ruoyi
 * @date 2025-03-06
 */
@RestController
@RequestMapping("/smartcity/huanjing/kongqizhiliang")
public class HuanjingKongqizhiliangController extends BaseController
{
    @Autowired
    private IHuanjingKongqizhiliangService huanjingKongqizhiliangService;

    /**
     * 查询空气质量列表
     */
    @GetMapping("/list")
    public TableDataInfo list(HuanjingKongqizhiliang huanjingKongqizhiliang)
    {
        startPage();
        List<HuanjingKongqizhiliang> list = huanjingKongqizhiliangService.selectHuanjingKongqizhiliangList(huanjingKongqizhiliang);
        return getDataTable(list);
    }

    /**
     * 导出空气质量列表
     */
    @Log(title = "空气质量", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HuanjingKongqizhiliang huanjingKongqizhiliang)
    {
        List<HuanjingKongqizhiliang> list = huanjingKongqizhiliangService.selectHuanjingKongqizhiliangList(huanjingKongqizhiliang);
        ExcelUtil<HuanjingKongqizhiliang> util = new ExcelUtil<HuanjingKongqizhiliang>(HuanjingKongqizhiliang.class);
        util.exportExcel(response, list, "空气质量数据");
    }

    /**
     * 获取空气质量详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(huanjingKongqizhiliangService.selectHuanjingKongqizhiliangById(id));
    }

    /**
     * 新增空气质量
     */
    @Log(title = "空气质量", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HuanjingKongqizhiliang huanjingKongqizhiliang)
    {
        return toAjax(huanjingKongqizhiliangService.insertHuanjingKongqizhiliang(huanjingKongqizhiliang));
    }

    /**
     * 修改空气质量
     */
    @Log(title = "空气质量", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HuanjingKongqizhiliang huanjingKongqizhiliang)
    {
        return toAjax(huanjingKongqizhiliangService.updateHuanjingKongqizhiliang(huanjingKongqizhiliang));
    }

    /**
     * 删除空气质量
     */
    @Log(title = "空气质量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(huanjingKongqizhiliangService.deleteHuanjingKongqizhiliangByIds(ids));
    }
}
